package cn.kivensoft.xlsx.reader;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public abstract class BaseCells {
	protected int index;
	protected boolean hidden;
	protected Sheet sheet;
	protected List<Cell> cells = new ArrayList<Cell>();

	public abstract void addCell(Cell cell);

	public BaseCells(int index) {
		this.index = index;
		this.hidden = false;
	}

	public BaseCells(int index, boolean hidden) {
		this.index = index;
		this.hidden = hidden;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int value) {
		index = value;
	}

	public boolean getHidden() {
		return hidden;
	}

	public void setHidden(boolean value) {
		hidden = value;
	}

	public Sheet getSheet() {
		return sheet;
	}

	public void setSheet(Sheet value) {
		sheet = value;
	}

	public List<Cell> getCells() {
		return cells;
	}

    public Cell getCell(int index) {
		return index >= cells.size() ? null : cells.get(index);
    }
    
	public String cellAsString(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getValue();
	}

	public Integer cellAsInteger(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsInteger();
	}

	public Double cellAsDouble(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsDouble();
	}

	public BigDecimal cellAsDecimal(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsDecimal();
	}

	public Date cellAsDate(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsDate();
	}

	public Date cellAsTime(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsTime();
	}

	public Date cellAsDateTime(int index) {
		Cell c = getCell(index);
		return c == null ? null : c.getAsDateTime();
	}

}
